﻿using System;
using System.Linq;
using WebChat.Models;

namespace WebChat.Models
{
    public class UserRepository
    {
        private ChannelDataClassesDataContext db;

        public UserRepository() 
        {
            db = new ChannelDataClassesDataContext();
        }

        public IQueryable<aspnet_User> showAllUsers() 
        {
            return db.aspnet_Users;
        }
        public aspnet_User showUser(String id)
        {
            aspnet_User user = (from o in db.aspnet_Users
                                where o.UserName.Equals(id)
                                select o).FirstOrDefault();
            return user;
        }

        public void updateUser(aspnet_User user)
        {
            db.SubmitChanges();
        }

        public void deleteUser(aspnet_User user)
        {
            db.aspnet_Users.DeleteOnSubmit(user);
            db.SubmitChanges();
        }
    }
}